<?
$email = $_POST["email"];

# TODO: check email vaildity, and then return if fail

$mysqli = new mysqli("db.fittiche.com", "woodstock", "whoareyou", "woodstock_prototype");
if (mysqli_connect_errno()) {
	printf("Connect failed: %s\n", mysqli_connect_error());
	exit();
}

# TODO: check email uniqueness, and then return if fail
$sql = "INSERT INTO mailing_list (email, status, join_date) VALUES (?, 'active', current_date() )";
$stmt = $mysqli->stmt_init();
$stmt->prepare($sql);
$stmt->bind_param("s", $email);
$stmt->execute();
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<h1>Woodstock mailing list</h1>
successfully added email: <?=$email?>
</body>
</html>
<?
$stmt->close();
$mysqli->close();
?>
